#include <Architect.hpp>
#include "WorkingTopFloor2.hpp"

WorkingTopFloor2::WorkingTopFloor2()
{
  style = CLASSIC; // a titre d'exemple
}

void WorkingTopFloor2::setBuiltIn()
{
  bv = new AABB(height, width, depth);
  
  Box* ceiling = new Box(0.3, width-0.3, depth-0.3);
  ceiling->translateOf(0.3, 0.3, height-0.3);
  addObject(ceiling);
  
  float i;
  
  float width_begin = (width-0.6-floor(width-0.6))/2;
  
  Box* b_l1 = new Box(height-0.3, width_begin+0.1, 0.3);
  b_l1->translateOf(0.3, 0.3, 0);
  addObject(b_l1);
  
  Box* b_l2 = new Box(height-0.3, width_begin+0.1, 0.3);
  b_l2->translateOf(0.3, depth-0.6, 0);
  addObject(b_l2);
  
  for (i=width_begin+0.3; i<=(width-1.3); i++)
  {	
    if ((int)(floor(i))%2 == 0)
	{
		Box* b1 = new Box(0.1, 0.9, 0.3);
		b1->translateOf(i+0.1, 0.3, 0.8);
		addObject(b1);
		
		Plane* p1 = new Plane(0.9, 0.8, true);
		p1->translateOf(i+0.1, 0.3, 0);
		p1->rotateOf(90, 0, 0);
		p1->setTransparency(0.8);
		addObject(p1);
		
		Box* b2 = new Box(0.1, 0.9, 0.3);
		b2->translateOf(i+0.1, 0.3, 2.2);
		addObject(b2);
		
		Plane* p2 = new Plane(0.9, 1.3, true);
		p2->translateOf(i+0.1, 0.3, 0.9);
		p2->rotateOf(90, 0, 0);
		p2->setTransparency(0.8);
		addObject(p2);
		
		Plane* p3 = new Plane(0.9, 0.4, true);
		p3->translateOf(i+0.1, 0.3, 2.3);
		p3->rotateOf(90, 0, 0);
		p3->setTransparency(0.8);
		addObject(p3);
		
		Box* b4 = new Box(0.1, 0.9, 0.3);
		b4->translateOf(i+0.1, depth-0.6, 0.8);
		addObject(b4);
		
		Plane* p4 = new Plane(0.9, 0.8, true);
		p4->translateOf(i+1, depth-0.3, 0.8);
		p4->rotateOf(90, 0, 180);
		p4->setTransparency(0.8);
		addObject(p4);
		
		Box* b5 = new Box(0.1, 0.9, 0.3);
		b5->translateOf(i+0.1, depth-0.6, 2.2);
		addObject(b5);
		
		Plane* p5 = new Plane(0.9, 1.3, true);
		p5->translateOf(i+1, depth-0.3, 2.2);
		p5->rotateOf(90, 0, 180);
		p5->setTransparency(0.8);
		addObject(p5);
		
		Plane* p6 = new Plane(0.9, 0.4, true);
		p6->translateOf(i+1, depth-0.3, 2.7);
		p6->rotateOf(90, 0, 180);
		p6->setTransparency(0.8);
		addObject(p6);
		
		if (i != width_begin)
		{
		  Box* b7 = new Box(height-0.3, 0.1, 0.3);
		  b7->translateOf(i, 0.3, 0);
		  addObject(b7);
		  Box* b8 = new Box(height-0.3, 0.1, 0.3);
		  b8->translateOf(i, depth-0.6, 0);
		  addObject(b8);
		}
	}
	else
	{
	    Box* b1 = new Box(height-0.3, 1, 0.3);
		b1->translateOf(i, 0, 0);
		addObject(b1);
		
	    Box* b2 = new Box(height-0.3, 1, 0.3);
		b2->translateOf(i, depth-0.3, 0);
		addObject(b2);
	}
  }
  
  Box* b_r1 = new Box(height-0.3, width-i-0.3, 0.3);
  b_r1->translateOf(i, 0.3, 0);
  addObject(b_r1);
  
  Box* b_r2 = new Box(height-0.3, width-i-0.3, 0.3);
  b_r2->translateOf(i, depth-0.6, 0);
  addObject(b_r2);
 
  float depth_begin = (depth-1.2-floor(depth-1.2))/2;
  
  for (i=0.6; i<=(depth-1.6); i++)
  {
    if ((int)(floor(i))%2 == 0)
	{
		Box* b1 = new Box(0.1, 0.3, 0.9);
		b1->translateOf(0.3, i+0.1, 0.8);
		addObject(b1);
		
		Plane* p1 = new Plane(0.9, 0.8, true);
		p1->translateOf(0.3, i+0.1, 0);
		p1->rotateOf(90, 90, 0);
		p1->setTransparency(0.8);
		addObject(p1);
		
		Box* b2 = new Box(0.1, 0.3, 0.9);
		b2->translateOf(0.3, i+0.1, 2.2);
		addObject(b2);
		
		Plane* p2 = new Plane(0.9, 1.3, true);
		p2->translateOf(0.3, i+0.1, 0.9);
		p2->rotateOf(90, 90, 0);
		p2->setTransparency(0.8);
		addObject(p2);
		
		Plane* p3 = new Plane(0.9, 0.4, true);
		p3->translateOf(0.3, i+0.1, 2.3);
		p3->rotateOf(90, 90, 0);
		p3->setTransparency(0.8);
		addObject(p3);
		
		Box* b4 = new Box(0.1, 0.3, 0.9);
		b4->translateOf(width-0.6, i+0.1, 0.8);
		addObject(b4);
		
		Plane* p4 = new Plane(0.9, 0.8, true);
		p4->translateOf(width-0.3, i+1, 0.8);
		p4->rotateOf(90, 90, 180);
		p4->setTransparency(0.8);
		addObject(p4);
		
		Box* b5 = new Box(0.1, 0.3, 0.9);
		b5->translateOf(width-0.6, i+0.1, 2.2);
		addObject(b5);
		
		Plane* p5 = new Plane(0.9, 1.3, true);
		p5->translateOf(width-0.3, i+1, 2.2);
		p5->rotateOf(90, 90, 180);
		p5->setTransparency(0.8);
		addObject(p5);
		
		Plane* p6 = new Plane(0.9, 0.4, true);
		p6->translateOf(width-0.3, i+1, 2.7);
		p6->rotateOf(90, 90, 180);
		p6->setTransparency(0.8);
		addObject(p6);
		
		if (i != depth_begin)
		{
		  Box* b7 = new Box(height-0.3, 0.3, 0.1);
		  b7->translateOf(0.3, i, 0);
		  addObject(b7);
		  Box* b8 = new Box(height-0.3, 0.3, 0.1);
		  b8->translateOf(width-0.6, i, 0);
		  addObject(b8);
		}
	}
	else
	{
	    Box* b1 = new Box(height-0.3, 0.3, 1);
		b1->translateOf(0, i, 0);
		addObject(b1);
		
	    Box* b2 = new Box(height-0.3, 0.3, 1);
		b2->translateOf(width-0.3, i, 0);
		addObject(b2);
	}
  }
  
  Box* b_r3 = new Box(height-0.3, 0.3, depth-i-0.6);
  b_r3->translateOf(0.3, i, 0);
  addObject(b_r3);
  
  Box* b_r4 = new Box(height-0.3, 0.3, depth-i-0.6);
  b_r4->translateOf(width-0.6, i, 0);
  addObject(b_r4);
  
  HappyTriangle* ht1 = new HappyTriangle(width-0.6, 0.3, 0.3, 90);
  ht1->rotateOf(0, 90, -90);
  ht1->translateOf(0.3, 0.3, height);
  addObject(ht1);
 
  HappyTriangle* ht2 = new HappyTriangle(width-0.6, 0.3, 0.3, 90);
  ht2->rotateOf(0, 90, 0);
  ht2->translateOf(0.3, depth-0.3, height);
  addObject(ht2);
  
  HappyTriangle* ht3 = new HappyTriangle(depth-0.6, 0.3, 0.3, 90);
  ht3->rotateOf(90, 0, 180);
  ht3->translateOf(0.3, depth-0.3, height);
  addObject(ht3);
  
  HappyTriangle* ht4 = new HappyTriangle(depth-0.6, 0.3, 0.3, 90);
  ht4->rotateOf(90, 0, -90);
  ht4->translateOf(width-0.3, depth-0.3, height);
  addObject(ht4);
}
